package com.qidian.mes.md.excel;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-04-12 18:38
 **/

public class WorkshopConverter implements Converter<Integer> {

    @Override
    public Integer convertToJavaData(ReadConverterContext<?> context) throws Exception {
        return context.getReadCellData().getStringValue().equals("正常") ? 1 : 0;
    }

    @Override
    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return new WriteCellData<>(value == 1 ? "正常" : "已停用");
    }
}
